package com.alpaak.common.utils.json;

import net.sf.json.JsonConfig;
import net.sf.json.processors.JsonValueProcessor;

/**
 * <p>标题: JsonDateValueProcessor.java</p>
 * <p>说明: json数据中Date转换</p>
 * <p>时间: 2014年8月6日</p>
 *
 * @author zqb
 * @version 1.0
 */

public class JsonStringValueProcessor implements JsonValueProcessor {

    public JsonStringValueProcessor() {
        super();
    }

   
    public JsonStringValueProcessor(String format) {
        super();
    }

   
    public Object processArrayValue(Object value, JsonConfig jsonConfig) {
        return process(value);
    }

   
    public Object processObjectValue(String key, Object value,
            JsonConfig jsonConfig) {
        return process(value);
    }

   
    private Object process(Object value) {
        try {
            if (value instanceof String) {
            	return value.toString();
            }
            return value == null ? null : value.toString();
        } catch (Exception e) {
            return "";
        }

    }

}